]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell-app: Improve prefix matches
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 5 Oct 2011 22:16:46 +0000 (00:16 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 13 Oct 2011 15:46:45 +0000 (17:46 +0200)
Currently we use a very strict definition of "prefix", where the
search term has to match at the very beginning of the searched
criteria (application name, executable name). Use a more liberal
definition by including matches where the preceding character is
a space (application name) or hyphen (executable name) as well;
as many applications use a prefix, this should improve the quality
of results.

https://bugzilla.gnome.org/show_bug.cgi?id=623372

src/shell-app.c

index 1055857309c9fa399b0941eac8efae2065c4b7ae..e6e31df09d1f56cf681c6e530780cb1354370df7 100644 (file)
@@ -1255,15 +1255,18 @@ _shell_app_match_search_terms (ShellApp  *app,
       current_match = MATCH_NONE;
 
       p = strstr (app->casefolded_name, term);
-      if (p == app->casefolded_name)
-        current_match = MATCH_PREFIX;
-      else if (p != NULL)
-        current_match = MATCH_SUBSTRING;
+      if (p != NULL)
+        {
+          if (p == app->casefolded_name || *(p - 1) == ' ')
+            current_match = MATCH_PREFIX;
+          else
+            current_match = MATCH_SUBSTRING;
+        }
 
       p = strstr (app->casefolded_exec, term);
       if (p != NULL)
         {
-          if (p == app->casefolded_exec)
+          if (p == app->casefolded_exec || *(p - 1) == '-')
             current_match = (current_match == MATCH_NONE) ? MATCH_PREFIX
                                                           : MATCH_MULTIPLE_PREFIX;
           else if (current_match < MATCH_PREFIX)